#ifndef LINEVALIDATOR_H
#define LINEVALIDATOR_H

#include <QRegExp>
#include <QString>

/**This class validates lines against given patterns. It can be used to determine if a line is a valid log line, if it is not, and it can extract the durationtime and the acctual statement that was run*/
class LineValidator
{
public:
    LineValidator();
    void setValidLinePattern(QString regexp);
    bool isValidLogLine(QString& line);

    void setInValidLinePattern(QString regexp);

    /**This is NOT just a logical negation of isValidLogLine since a line can be either
        - a valid log line
        - a continuation of a valid log line
        - an invalid logline
        - a continuation of an invalid logline.
        So this is equally important to describe. It checks against the m_inValidLinePattern but if that does not match, it checks to make sure
        the line is not a valid Line.*/
    bool isInValidLogLine(QString& line);

    void setDurationExtractionPattern(QString regexp);
    void setStatementExtractionPattern(QString regexp);

    bool extractDurationAndStatement(QString& line,qreal& duration,QString& statement);
    void annonymizeStatement(QString&);

    QString getValidStringSyntax(){return m_validString;}
    QString getInvalidStringSyntax(){return m_inValidString;}
    QString getDurationStringSyntax(){return m_durationString;}
    QString getStatementStringSyntax(){return m_statementString;}
private:
    QRegExp m_validLinePattern;
    QString m_validString;
    QRegExp m_inValidLinePattern;
    QString m_inValidString;
    QRegExp m_durationPattern;
    QString m_durationString;
    QRegExp m_statementPattern;
    QString m_statementString;
};

#endif // LINEVALIDATOR_H
